<#assign pojoNameLower = pojo.shortName.substring(0,1).toLowerCase()+pojo.shortName.substring(1)>
<#assign getIdMethodName = pojo.getGetterSignature(pojo.identifierProperty)>
<#assign setIdMethodName = 'set' + pojo.getPropertyName(pojo.identifierProperty)>
<#assign identifierType = pojo.getJavaTypeName(pojo.identifierProperty, jdk5)>
package ${basepackage}.webapp.action;

import ${basepackage}.model.${pojo.shortName};
import org.sbbs.base.searcher.SearchFilterBuilder;
import org.sbbs.base.webapp.action.BaseJqgridPagedAction;
import ${basepackage}.service.${pojo.shortName}Manager;
import org.sbbs.base.pager.IPager;
import org.sbbs.base.pager.impl.JqgridPagerImpl;
import org.sbbs.base.searcher.SearchFilter;
<#if fType=="2">
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.sbbs.base.pagequery.hibernate.CriteriaUtil;
import org.sbbs.base.pagequery.hibernate.CustomCriteria;
import org.sbbs.base.searcher.SearchOperator;
</#if>
public class ${pojo.shortName}PagedAction extends BaseJqgridPagedAction {
	private ${pojo.shortName}Manager	${pojoNameLower}Manager;
	public ${pojo.shortName}Manager get${pojo.shortName}Manager() {
		return ${pojoNameLower}Manager;
	}

	public void set${pojo.shortName}Manager(${pojo.shortName}Manager ${pojoNameLower}Manager) {
		this.${pojoNameLower}Manager = ${pojoNameLower}Manager;
	}
<#if fType=="2" && pojo.shortName==detailShortName>
	private ${masterIdType} ${masterIdName};

	<#assign mIdMethodName = masterIdName.substring(0,1).toUpperCase()+masterIdName.substring(1)>
	public ${masterIdType} get${mIdMethodName}() {
		return ${masterIdName};
	}

	public void set${mIdMethodName}(${masterIdType} ${masterIdName}) {
		this.${masterIdName} = ${masterIdName};
	}
	</#if>
	@Override
	public Class getSearchEntityClazz() {
		return ${pojo.shortName}.class;
	}

	@Override
	public int getSearchFilterType() {
		return SearchFilterBuilder.PROPERTY_FILTER;
	}

	@Override
	public String gridPageList() {
        this.setSearchFilterType( SearchFilterBuilder.PROPERTY_FILTER );
        <#if fType=="2" && pojo.shortName==detailShortName>
        this.setCustomCriteria(new ${pojo.shortName}CustomCriteria(this.${masterIdName}));
        </#if>
        try {
            IPager pager = new JqgridPagerImpl( getRequest() );
            SearchFilter sf = SearchFilterBuilder.buildSearchFilter( getRequest(), this.getSearchFilterType() );
            if ( this.getCustomCriteria() != null )
                pager = this.${pojoNameLower}Manager.pagedQuery( this.getSearchEntityClazz(), pager, sf, this.getCustomCriteria() );
            else
                pager = this.${pojoNameLower}Manager.pagedQuery( this.getSearchEntityClazz(), pager, sf );

            this.pageList = pager.getList();
            records = pager.getTotalNumberOfRows();
            total = pager.getTotalNumberOfPages();
            page = pager.getPageNumber();
        }
        catch ( Exception e ) {
            log.error( "${pojoNameLower}GridList Error", e );
        }
        return SUCCESS;
    }
}
<#if fType=="2" && pojo.shortName==detailShortName>
class ${pojo.shortName}CustomCriteria implements CustomCriteria {
	private ${masterIdType}	parentId;

	${pojo.shortName}CustomCriteria(${masterIdType} parentId) {
		this.parentId = parentId;
	}

	@Override
	public Criteria getCustomCriteria(Class clazz, Session session) throws Exception {
		Criteria cr = session.createCriteria(clazz);
		Criterion crn = CriteriaUtil.createCriterion(clazz, "${masterShortNameLower}.${masterIdName}", SearchOperator.eq.getOpr(), parentId+"");
		return cr.add(crn);
	}

}
</#if>
